﻿using Way.Contract.Data;
using Way.Contract.Data.ControllerData;
using Way.Contract.MVC;
using System;
using Way.Bus.WMS.Controllers;
using Way.Bus.WMS.ST.Controllers;
using Way.Bus.WMS.ST.Model;
using Way.EAP.DataAccess.Regulation;
using System.Collections.Generic;
using Way.EAP.DataAccess.Entity;
namespace Way.Bus.WMS.ST.Controllers.Custemer
{
   

    public class MaterialsController : Way.Bus.WMS.Controllers.MaterialsController
    {
        public MaterialsController() : base(new ST_Materials())
        {
        }
        
        protected override ReadTable OnForeignLoad(IModel model, loadItem item)
        {
            if (base.fdata.filedname == "STAY10")
            {
                item.rowsql = Common.GetCustemerSQL(item.rowsql);
            }
            return base.OnForeignLoad(model, item);
        }

        protected override void OnInitViewChildItem(ModelData data, ItemData item)
        {
            InitMaterials(data, item);
        }
        public static void InitMaterials(ModelData data, ItemData item)
        {
            if (data.name.EndsWith("Materials"))
            {
                item.visible = false;
                if (item.IsField("code"))
                {
                    item.visible = true;
                    item.index = 0;
                }
                if (item.IsField("FNAME"))
                {
                    item.visible = true;
                    item.index = 3;
                }
                if (item.IsField("STAY10"))
                {
                    item.visible = true;
                    item.index = 1;
                }
                if (item.IsField("FMODEL"))
                {
                    item.visible = true;
                    item.index = 4;
                }
                if (item.IsField("CUSTOMEAN13"))
                {
                    item.visible = true;
                    item.index = 2;
                }
                if (item.IsField("ClassID"))
                {
                    item.visible = true;
                    item.index = 1;
                }
                if (item.IsField("BATCH"))
                {
                    item.visible = true;
                    item.index = 5;
                }
                if (item.IsField("ISPERIOD"))
                {
                    item.visible = true;
                    item.index = 6;
                }
                if (item.IsField("SEQUENCECODE"))
                {
                    item.visible = true;
                    item.index = 7;
                }
                if (item.IsField("IsDisable"))
                {
                    item.visible = true;
                    item.index = 8;
                }
                if (item.IsField("Remark"))
                {
                    item.visible = true;
                    item.index = 9;
                }
            }
            else
            {
                data.visible = false;
            }
        }
    }
}

